/**
* 创建者：lym
* 该页面用于：
* 创建时间： 2020-01-02 02:52:51
*/
import ArchivesTree from '@/components/luyiming/ArchivesTree/index.vue';
import EnterpriseInfo from './components/EnterpriseInfo.vue';
import PermitInfo from './components/PermitInfo.vue';
import AreaInfo from './components/AreaInfo.vue';
import InstrumentInfo from './components/InstrumentInfo.vue';
import PatrolInfo from './components/PatrolInfo.vue';
import UseSourceDevice from './components/UseSourceDevice.vue';
import DeviceMonitor from './components/DeviceMonitor.vue';
import SourceInfo from './components/SourceInfo.vue';
import VideoInfo from './components/VideoInfo.vue';

import enterprise from './enterpriseList.vue';


import { debounce } from '@/utils';

export default {
	name: 'RcimArchives_view',
	components: {
		ArchivesTree,
		EnterpriseInfo,
		PermitInfo,
		AreaInfo,
		InstrumentInfo,
		PatrolInfo,
		UseSourceDevice,
		DeviceMonitor,
		SourceInfo,
		VideoInfo,
		enterprise,
	},
    // 数据
	data() {
		return {
			smallStyle: false,
			resizeHandOwn: null,
			showTree: false,
			// 面包屑导航?
			navs: [],
			content: {
				id: "EnterpriseInfo",
				name: "企业信息"
			},
			showDetail: false,
			editDetail: false,
			menus: [
				{
					id: "EnterpriseInfo",
					name: "企业信息",
					iconName: "iconqiyeguanli",
				},
				{
					id: "PermitInfo",
					name: "许可证信息",
					iconName: "iconzhongshenguanli",
				},
				{
					id: "AreaInfo",
					name: "场所信息",
					iconName: "iconGeologyMonitorPSOA",
				},
				{
					id: "InstrumentInfo",
					name: "数采仪信息",
					iconName: "iconrifangwenqushi",
				},
				{
					id: "PatrolInfo",
					name: "巡检仪信息",
					iconName: "iconshouji",
				},
				{
					id: "UseSourceDevice",
					name: "用源设备",
					iconName: "iconshebeileimenkouji",
				},
				{
					id: "DeviceMonitor",
					name: "设备监控因子",
					iconName: "iconjiankongyinzi",
				},
				{
					id: "SourceInfo",
					name: "源信息",
					iconName: "iconradiation",
				},
				{
					id: "VideoInfo",
					name: "视频信息",
					iconName: "iconshipinjiankong",
				},
			],
			isShowList: true,
			entData: {},
			setDefExtendId: "",
		}
	},
    // 监听
    watch: {

    },
    // Vue实例初始化完成
    created() {

    },
    // Vue挂载完成
    mounted() {
		this.resizeHandOwn = debounce(() => {
			this.resizePage()
		}, 300)
		this.resizePage()
		window.addEventListener('resize', this.resizeHandOwn)
		const entId = this.$route.query.enterpriseId
		const xkz = this.$route.query.xkz
		if(entId){
			this.toDetail({
				id: entId
			})
			if(xkz){
				return setTimeout(() => {
					this.setDefExtendId = "PermitInfo";
					this.content = {
						id: "PermitInfo",
						name: "许可证信息"
					}
				}, 500)
			}
			setTimeout(() => {
				this.setDefExtendId = "EnterpriseInfo";
				this.content = {
					id: "EnterpriseInfo",
					name: "企业信息"
				}
			}, 500)
		}
    },
    // Vue实例销毁前
    beforeDestroy(){

    },
    // 挂载的方法
    methods: {
        /**
        * 方法描述
        */
        exampleFunc(){
            return void 0
		},
		/**
		 * @desc 许可证信息编辑
		 */
		handlePernit(){
			this.$refs.compents.handleEdit()
		},
		/**
		 * @desc 监听页面隐藏左侧列表
		 */
		resizePage(){
			let windowWidth = document.body.clientWidth;
			if(windowWidth < 1280){
				this.smallStyle = true;
				this.showTree = true;
			}else{
				this.smallStyle = false;
				this.showTree = false;
			}
		},
		/**
		 * @desc 关闭详情
		 */
		closeDetail() {
			this.showDetail = false
		},
		/**
		 * @desc 切换显示左侧列表
		 */
		changeShowBar(){
			this.showTree = !this.showTree
		},
		/**
		 * @desc 处理点击左侧列
		 */
		treeHandle(...rest){
			const [node, Nodes, vueExm] = rest
			// const navs = [];
			// let start = Nodes;
			// while( start.parent ){
			// 	navs.push( start.data.name )
			// 	start = start.parent
			// }
			// navs.reverse()
			// this.navs = navs;
			if(!this.entData?.id && node.name !== '企业信息'){
				return this.$message({
					type:"warning",
					message: "请先添加企业",
				})
			}
			this.content = node
		},
		/**
		 * @desc 点击详情
		 * @param {Object} row 表格行数据
		 */
		toDetail(row) {
			this.entData = row
			console.log(this.entData);

			this.isShowList = false
		},
		/**
		 * @desc 返回企业信息
		 */
		returnList() {
			this.isShowList = true
			this.showDetail = false
			this.editDetail = false
			this.content = {
				id: "EnterpriseInfo",
				name: "企业信息"
			}
			if(this.entData) {
				this.entData = {}
			}
		}
    },
}
